feat(http): Add pluggable HttpAdapter interface for HTTP transport - #334
Merged
Conversation
douglasmiller
force-pushed
the
http-adapter
branch
3 times, most recently
from
August 11, 2026 00:33
9339862 to
b162cca
Compare
Introduce HttpAdapter, HttpResponse, and DefaultHttpAdapter in the com.recurly.v3.http package. DefaultHttpAdapter wraps OkHttp and owns gzip negotiation, connection management, and timeout configuration. BaseClient now builds its headers map directly and delegates all transport to the injected adapter, removing the OkHttp dependency from the SDK core. ClientOptions gains setHttpAdapter() as the injection point. HeaderInterceptor is removed; its User-Agent logic moves to BaseClient. Co-Authored-By: Claude <noreply@anthropic.com>
douglasmiller
force-pushed
the
http-adapter
branch
2 times, most recently
from
August 11, 2026 05:32
2858608 to
14d386b
Compare
douglasmiller
marked this pull request as ready for review
August 11, 2026 05:46
douglasmiller
force-pushed
the
http-adapter
branch
3 times, most recently
from
August 11, 2026 16:54
1662015 to
b237685
Compare
Replace OkHttp transport with java.net.HttpURLConnection; remove okhttp and logging-interceptor compile dependencies. Preserve debug logging behind RECURLY_INSECURE + RECURLY_DEBUG using System.out.println. Fix 411 errors on POST/PUT with null body by sending Content-Length: 0, matching OkHttp prior behavior. Add contract tests for this case. Update the implementation guide to use OkHttp as the example adapter instead of java.net.http.HttpClient. Co-Authored-By: Claude <noreply@anthropic.com> feat: Add gzip response decompression to DefaultHttpAdapter DefaultHttpAdapter now sets Accept-Encoding: gzip on outgoing requests (unless the caller already set one) and transparently decompresses gzip-encoded response and error bodies via GZIPInputStream, matching the behavior OkHttp provided automatically before the HttpURLConnection migration. content-encoding and content-length are stripped from the returned headers once decompressed since they no longer describe the decompressed body. Co-Authored-By: Claude <noreply@anthropic.com> fix: Exclude WireMock-dependent tests from testCompile on JDK 8 WireMock 3.x ships Java 11 class files, which javac on a JDK 8 toolchain cannot read from the classpath regardless of source/target level. @DisabledOnJre(JRE.JAVA_8) only skips execution, not compilation, so the Java 8 CI job was failing to build. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> fix: Update RequestOptions header tests for HttpAdapter migration Rebase onto v3-v2021-02-25 merged in idempotency-key/custom-header tests written against the old OkHttp-based BaseClient. Rewrite them against the HttpAdapter mock so they compile and assert against the headers map passed to httpAdapter.execute. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
douglasmiller
force-pushed
the
http-adapter
branch
from
August 11, 2026 17:31
b237685 to
9ba6427
Compare
cbarton
approved these changes
Aug 11, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Introduce a pluggable
HttpAdapterinterface that decouples the Recurly Java clientfrom any specific HTTP library. Replace the previous OkHttp-based implementation with
a
DefaultHttpAdapterbuilt on Java's built-inHttpURLConnection, removing the OkHttpdependency. Add automatic gzip decompression for HTTP responses and expose
ClientOptions.setHttpAdapter()so callers can inject a custom implementation.Testing
Setup / Prerequisites:
Happy Path:
mvn testExpected: BUILD SUCCESS, 0 failures
ClientOptionswith a customHttpAdapterimplementation and verifythe client uses it instead of the default.
Expected: custom adapter is called for each API request
Edge Cases / Error Cases:
Content-Encoding: gzipheaderExpected: body is transparently decompressed before parsing
IOExceptionExpected: wrapped in the appropriate Recurly exception type
Automated Test Coverage:
mvn testHttpAdapterContract,DefaultHttpAdapterContractTest,HttpResponseTest,BaseClientTest,HeaderInterceptorTest🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com